home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / MACVOGL- / EXAMPLES / SINEWAVE.C < prev    next >
C/C++ Source or Header  |  1992-07-19  |  872b  |  75 lines

  1. #ifdef SGI
  2. #include "gl.h"
  3. #include "device.h"
  4. #else
  5. #include "vogl.h"
  6. #include "vodevice.h"
  7. #endif
  8.  
  9. #ifndef TC
  10. #include <math.h>
  11. #else
  12. extern double sin(), cos();
  13. #endif
  14.  
  15. #ifndef PI
  16. #define PI    3.14159261358979
  17. #endif
  18.  
  19. #define    STEP    PI / 180.0
  20.  
  21. main()
  22. {
  23.     float a;
  24.     int i;
  25.     float v[2];
  26.     short    val;
  27.  
  28.     winopen("bgnline/endline test");
  29.     unqdevice(INPUTCHANGE);
  30.     qdevice(KEYBD);
  31.     color(BLACK);
  32.     clear();
  33.     ortho2(-0.5, 2 * PI + .5, -1.5, 1.5);
  34.  
  35.     color(GREEN);
  36.     bgnline();
  37.         v[0] = -0.5;
  38.         v[1] = 0.0;
  39.         v2f(v);
  40.  
  41.         v[0] = 2 * PI + .5;
  42.         v[1] = 0.0;
  43.         v2f(v);
  44.     endline();
  45.  
  46.     color(RED);
  47.     bgnline();
  48.         v[0] = 0.0;
  49.         v[1] = -1.3;
  50.         v2f(v);
  51.  
  52.         v[0] = 0.0;
  53.         v[1] = 1.3;
  54.         v2f(v);
  55.     endline();
  56.  
  57.  
  58.     color(YELLOW);
  59.     bgnline(); 
  60.         v[0] = v[1] = 0.0;
  61.         v2f(v);
  62.  
  63.         for (a = 0.0; a <= 2 * PI; a += STEP) {
  64.             v[0] = a;
  65.             v[1] = sin(a);
  66.             v2f(v);
  67.         }
  68.     endline();
  69.  
  70.     qread(&val);
  71.  
  72.     gexit(); 
  73. }
  74.  
  75.